home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 19
/
Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso
/
Aminet
/
comm
/
www
/
SearchAdr.lha
/
searchadr
/
SearchAdr.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1997-04-13
|
5KB
|
219 lines
/* SearchAdr.rexx
* Arexx program to search for URL`s & eMail Adresses in a
* Textfile,Guide,HTML,... & Copy it to Clipboard
*
* requirements:
* - rexxreqtools.library
* - rexxtricks.library
*
* usage:
* rx SearchAdr [Filename]
* (Select your favor language in Tooltypes of Icon)
*
* © By Bostjan Dolanec <basti@stuttgart.netsurf.de>
* $VER: SearchAdr.rexx 1.3 (11.4.1997)
*/
Options Results
arg filename
if left(filename,1)='"' then do
l=length(filename)
filename=substr(filename,2,l-2)
end
lf=D2C(10)
if ~show("L","rexxreqtools.library") then do
if ~addlib('rexxreqtools.library',5,-30) then do
lib="rexxreqtools.library"
call nolib lib
end
end
if ~show("L","rexxtricks.library") then do
if ~addlib("rexxtricks.library",5,-30) then do
lib="rexxtricks.library"
call nolib lib
end
end
pfad=""
if gettooltypes("SearchAdr.rexx",destvar) then do
do i=1 to destvar.0
sprache=upper(destvar.i)
if sprache="DEUTSCH" then do
frtexthead = "Textdatei wählen"
frbutton = "_Suchen"
ioerrtext = "Datei konnte nicht geöffnet werden:"
listtitleI = "Ich fand "
listtitleII = " Adresse(n) in "
fenster.gadgettext = "_Clipboard|_Neues File|_Ende"
noadrreqI = "Ich konnte in:"lf||'"'
noadrreqII = '"'||lf"weder URL`s noch eMail Adressen finden.."
noadrhead = "Keine Adressen gefunden"
noadrbutton = "_Neues File|_Ende"
end
if sprache="ENGLISH" then do
frtexthead = "Select Textfile"
frbutton = "_Search"
ioerrtext = "I can`t open:"
listtitleI = "I found "
listtitleII = " address(es) in "
fenster.gadgettext = "_Clipboard|_New File|_End"
noadrreqI = "I can`t find in:"lf||'"'
noadrreqII = '"'||lf"any URL`s or eMail addresses."
noadrhead = "No addresses found"
noadrbutton = "_New File|_End"
end
end
end
/*------------------------------------------------------------*/
neuesfile:
z=0
wort="."
if pfad="" then pfad="RAM:"
if filename="" then filename=rtfilerequest(pfad,,frtexthead,frbutton,"rt_reqpos=reqpos_centerwin",check)
if filename="" then exit
pfad=pathpart(filename)
datei=filepart(filename)
len=length(pfad)
if len>10 then len=10
header='"'||left(pfad,len)||"..."||datei||'"'
if ~open(source,filename,R) then do
dummy = rtezrequest(ioerrtext||lf||filename,'_OK','IO Error','rt_reqpos=reqpos_centerwin')
exit
end
do while eof(source)=0
zeile=readln(source)
if length(zeile)>5 then do
idx=index(upper(zeile),"HTTP:")
if idx>0 then call grab
else do
idx=index(upper(zeile),"WWW.")
if idx>0 then call grab
end
if index(zeile,"@")>0 then call email
end
end
close(source)
if z>0 then do
fenster.title = listtitleI||z||listtitleII||header
fenster.font = "SCREEN"
fenster.multiselect = "TRUE"
fenster.sort = "TRUE"
liste:
dummy=viewlist(adr,fenster,destvar)
if destvar.gadget=2 then call neu
if destvar.0=0 then exit
if destvar.0>1 then do i=2 to destvar.0
destvar.1=destvar.1||lf||destvar.i
end
if destvar.1="" then call liste
if destvar.gadget=0 then exit
writeclipboard(0,destvar.1)
call liste
end
check = rtezrequest(noadrreqI||filename||noadrreqII,noadrbutton,noadrhead,'rt_reqpos=reqpos_centerwin')
if check=1 then call neu
exit
/* ----------------------------- Unterprogramme ------------------------- */
grab:
len=length(zeile)
len=len-idx
fidx.1=index(zeile," ",idx)
if fidx.1=0 then fidx.1=1000
fidx.2=index(zeile,'"',idx)
if fidx.2=0 then fidx.2=1000
fidx.3=index(zeile,")",idx)
if fidx.3=0 then fidx.3=1000
fidx.4=index(zeile,">",idx)
if fidx.4=0 then fidx.4=1000
fidx.5=index(zeile,"<",idx)
if fidx.5=0 then fidx.5=1000
fidx=min(fidx.1,fidx.2,fidx.3,fidx.4,fidx.5)
if fidx=1000 then fidx=0
if fidx>0 then wort=substr(zeile,idx,fidx-idx)
else wort=right(zeile,len+1)
if length(wort)<8 then return
call neueadr
return
/*-----------------------------------------------------------*/
email:
idx=index(zeile,"@")
if idx=1 then return
aidx.1=lastpos(" ",zeile,idx)
aidx.2=lastpos('"',zeile,idx)
aidx.3=lastpos("(",zeile,idx)
aidx.4=lastpos("<",zeile,idx)
aidx.5=lastpos(">",zeile,idx)
aidx.6=lastpos(":",zeile,idx)
aidx=max(aidx.1,aidx.2,aidx.3,aidx.4,aidx.5,aidx.6)+1
if aidx=idx then return
fidx.1=index(zeile," ",idx)
if fidx.1=0 then fidx.1=1000
fidx.2=index(zeile,'"',idx)
if fidx.2=0 then fidx.2=1000
fidx.3=index(zeile,")",idx)
if fidx.3=0 then fidx.3=1000
fidx.4=index(zeile,">",idx)
if fidx.4=0 then fidx.4=1000
fidx.5=index(zeile,"<",idx)
if fidx.5=0 then fidx.5=1000
fidx.6=index(zeile,"{",idx)
if fidx.6=0 then fidx.6=1000
fidx=min(fidx.1,fidx.2,fidx.3,fidx.4,fidx.5,fidx.6)
if fidx=1000 then fidx=0
if fidx=0 then fidx=length(zeile)+1
if fidx<5 then return
wort=substr(zeile,aidx,fidx-aidx)
len=length(wort)
if len<6 then return
if index(wort,"@")<3 then return
if index(wort,"@")>len-3 then return
call neueadr
return
/*-----------------------------------------------------------*/
neu:
if z>0 then dummy=stemremove(adr,1,z)
filename=""
call neuesfile
/*-----------------------------------------------------------*/
neueadr:
if lsearch(wort,adr)=(-1) then do
z=z+1
adr.0=z
adr.z=wort
end
return
/*-----------------------------------------------------------*/
nolib:
open("error","CON:160/50/320/100/Missing Library")
writeln("error","Please install the"||lf)
writeln("error",'"'||lib||'"'||lf)
writeln("error","to your LIBS: Directory"||lf)
writeln("error","(You find them in Aminet)")
zeit=time("S")
do until time("S")=zeit+5
end
exit